package com.atguigu.tingshu.common.util;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AssertUtil {

    public static void resultAssert(Result result, ResultCodeEnum codeEnum) {

        if (result == null
                || !result.getCode() .equals( ResultCodeEnum.SUCCESS.getCode())
                || result.getData() == null) {
            log.error("远程调用失败");
            throw new RuntimeException(codeEnum.getMessage());
        }
    }
   // 空值判断
    public static void isNull(Object object) {
        if (object == null) {
            throw new RuntimeException(object.toString()+"参数为空");
        }
    }
    public static void resultAssertMayNull(Result result, ResultCodeEnum codeEnum) {

        if (result == null
                || !result.getCode() .equals( ResultCodeEnum.SUCCESS.getCode())) {
            log.error("远程调用失败");
            throw new RuntimeException(codeEnum.getMessage());
        }
    }

}
